import entity.MsgXmlEntity;
import org.junit.Test;
import util.aes.AesException;
import util.aes.WXBizMsgCrypt;
import util.api.ApIURL;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by thinkjoy on 2017/9/4.
 */
public class testdate {

    @Test
    public void test1() throws ParseException {
        Date date=new Date();
        SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd ");
        String workdate=format.format(date)+"09:00:00";
        System.out.println(workdate);
        Date date1=format.parse(workdate);
        System.out.println(date1.getTime()/1000);
    }

    @Test
    public void test2() throws JAXBException, AesException {
        MsgXmlEntity msgXmlEntity=new MsgXmlEntity("123456","987654",
                13465465,"text","你好吗?");
        JAXBContext jbt=JAXBContext.newInstance(MsgXmlEntity.class);
        StringWriter sw = new StringWriter();
        Marshaller ms=jbt.createMarshaller();
        ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        ms.setProperty(Marshaller.JAXB_FRAGMENT, true);
        ms.marshal(msgXmlEntity,sw);
        System.out.println(sw.toString());
    }
}
